﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BulldogCMS.Data.Fields;

namespace BulldogCMS.Data.DataContext
{
    public class MemoryDataContext : IDataContext
    {
        private List<DataChanges> _dataChanges = new List<DataChanges>();

        public void AddChange(Guid nodeID, string fieldName, IField field)
        {
            DataChanges dataChange = this._dataChanges.Where(p => p.NodeID == nodeID && p.FieldName == fieldName).FirstOrDefault();
            if (dataChange != null)
            {
                dataChange.Field = field;
            }
            else
            {
                this._dataChanges.Add(new DataChanges()
                {
                    NodeID =    nodeID,
                    FieldName = fieldName,
                    Field =     field
                });
            }
        }


    }
}
